<%-- 
    Document   : jsxm
    Created on : 2016-8-10, 9:41:00
    Author     : cxhd
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <%@include file="../../link.jsp" %>
        <title>计算项目</title>
    </head>
    <body ng-app="jsxm" ng-controller="ppManager">
        <style>
            div{background-color: #FFF}
            tr>th{ padding: 1px}
            tr:hover,tr.hover{background:#F2F2F2;}
            input{font-weight: bold}
            /*.allLeft{float: left;width: 40px}*/
        </style>
        <div >


            <div style="float: left;width:26%;">
                <div class="wrapper bg b-b" style="height: 48px;">
                    <!--<button class="btn btn-sm btn-success pull-right" ui-toggle-class="timeline-center" target=".timeline">Center</button>-->
                    <div>  样本类型：
                        <select ng-model="PK" ng-options="sam.PK as sam.SAMPLEDESCRIBE for sam in sams" ng-change="getLisTest()"  style="width: 100px" >
                        </select>  </div>
                    <div>
                        项目拼音：<input type="text" ng-model="TESTID" style="width:90px" ng-change="getLisTestByT()"/> 
                        <!--<button ng-click="getLisTestByPy()" >收索</button>-->
                    </div>
                    <!--<button ng-click="getLisTest()">收索</button>-->
                </div>
                <div class="wrapper" >
                    <form class="ng-pristine ng-valid">
                        <table  class="table table-striped table-bordered  table-hover"  id="tab3"  >
                            <tr>
                                <th class="table-id"><input type="checkbox"></th>
                                <th class="table-title">项目代码</th>
                                <th class="table-title">项目名</th>
                            </tr>
                            <tr  ng-repeat="test in tests" ng-click="checkTest($index)" id="tr{{$index}}" class="xzh">
                                <td><input type="checkbox" ng-model="test.check"></td>
                                <td>{{test.TESTID}}</td>
                                <td>{{test.CHINESENAME}}</td>   
                            </tr>
                        </table>
                    </form>
                    <footer class="panel-heading">
                        <div class="row">
                            <div style="text-align: center" >                
                                <pagination ng-change="pageChanged()" previous-text="上一页" next-text="下一页" first-text="第一页" last-text="最后一页" ng-model="data.currentPage" items-per-page="data.pageSize" total-items="data.bigTotalItems" ng-model="data.bigCurrentPage" max-size="data.maxSize" class="pagination-sm" boundary-links="true" rotate="false" num-pages="numPages"></pagination>

                            </div>
                        </div>
                    </footer>
                </div>

            </div>
            <div style="float: left;width:20%;">
                <!--                <div class="wrapper bg b-b" style="height: 48px;">
                                    <button class="btn btn-sm btn-success pull-right" ui-toggle-class="timeline-center" target=".timeline">Center</button>
                                    <h4 class="m-n font-thin">收费项目浏览与选择</h4>
                                </div>
                                <div class="wrapper" >
                                    <form class="ng-pristine ng-valid">
                                        <table  class="table table-striped table-bordered  table-hover"   >
                                            <tr >
                                                <th class="table-id">序号</th>
                                                <th class="table-title">收费项目名</th>
                                                <th class="table-title">价格 </th>
                                            </tr>
                                            <tr  ng-repeat="cit in cits" ng-click="checkCharginitem(cit)">
                                                <td>{{$index}}</td>
                                                <td>{{cit.ITEMNAME}}</td>
                                                <td>{{cit.PRICE}}</td>
                                            </tr>
                                        </table>
                                    </form>
                                </div>-->
            </div>
            <div style="float: left;width:48%;">
                <div class="wrapper bg b-b" style="height: 48px;">
                    符号选择
                    <!--                当前收费项目:<input type="text" ng-model="ITEMNAME"/>
                                    <button class="btn m-b-xs btn-sm btn-primary btn-addon" ng-click="addLisCharginitemTest()"><i class="fa fa-save"></i>添加项目</button>-->

                </div>
                <div>
                    <table class="allLeft">
                        <tr class="allLeft-tr" style="float: left">
                            <td  ><button style="float: left;width: 40px">+</button></td>
                        </tr>
                        <tr style="float: left">
                            <td><button style="float: left;width: 40px">-</button></td>
                        </tr>
                        <tr style="float: left">
                            <td><button style="float: left;width: 40px">*</button></td>
                        </tr>
                        <tr style="float: left">
                            <td><button style="float: left;width: 40px">/</button></td>
                        </tr>
                        <tr style="float: left">
                            <td><button style="float: left;width: 40px">(</button></td>
                        </tr>
                        <tr style="float: left">
                            <td><button style="float: left;width: 40px" >)</button></td>
                        </tr>
                    </table>
                </div>
            </div>
            <div class="wrapper" ><!--
                    <form class="ng-pristine ng-valid">
                        <table  class="table table-striped table-bordered  table-hover">
                            <tr>
                                <th class="table-id">收费项目名</th>
                                <th class="table-title">项目名</th>
                                <th class="table-title">项目代码</th>
                                <th class="table-title">通道号</th>
                                <th class="table-title">操作</th>
                            </tr>
                            <tr  ng-repeat="citt in citts" >
                                <td>{{ppdt.DEVICENAME}}</td>
                                <td>{{citt.ITEMID1}}</td>
                                <td>{{citt.TESTID1}}</td>
                                <td>{{citt.TESTID}}</td>
                                <td><button ng-click="deleteLisCharginitemTest(citt)">删除该匹配</button> 
                                   
                                </td>
                            </tr>
                        </table>
                    </form>
                </div>-->
                <div>当前选择：<input  type="text"> <button  >生成新项目</button></div>
                <div>
                    <table>
                        <tr>
                            <td>项目代码：<input type="text" ></td>
                        </tr>
                        <tr>
                            <td>项目名称：<input type="text" ></td>
                        </tr>
                        <tr>
                            <td>项目单位：<input type="text" ></td>
                        </tr>
                        <tr>
                            <td>项目代码：<input type="text" ></td>
                        </tr>
                    </table>
                </div>
            </div>
            <!--</div>-->

        </div>
    </body>

    <script>
        angular.module("jsxm", ['baseModule', 'ui.bootstrap'])
                .controller("ppManager", function ($scope, $http) {
                    $scope.tests = [];
                    $scope.cits = [];
                    $scope.DEVICENAME = "";

                    $scope.getSamp = function () {//样本类型显示
                        $.post("citemtest/getLisSam", function (data) {
                            if (data) {
                                $scope.sams = data;
                                $scope.$apply();
                            }
                        })
                    }

                    $scope.data = {currentPage: 1};
                    $scope.pageChanged = function () {
                        $scope.getLisTestByT();
                    };
                    $scope.data.maxSize = 1;
                    $scope.data.bigTotalItems = 20;
                    $scope.data.bigCurrentPage = 1;
                    $scope.data.pageSize = 10;
                    $scope.getSamp();
                    $scope.getLisTest = function () {//通过样本类型筛选项目
                        $.post("citemtest/getLisTest", {PK: $scope.PK}, function (data) {
                            if (data) {
                                $scope.tests = data;

                                $scope.$apply();
                            }
                        })
                    }
                    $scope.TESTID = "";
                    $scope.getLisTestByT = function () {//通过拼音筛选项目
                        $.post("citemtest/getLisTestByPy", {TESTID: $scope.TESTID, pageSize: $scope.data.pageSize, currentPage: $scope.data.currentPage}, function (data) {
                            console.log(data);
                            if (data) {
                                $scope.tests = data.list;
                                $scope.data.bigTotalItems = data.totalRow;
                                $scope.$apply();
                            }
                        })
                    }
                    $scope.getLisTestByT();
                    $scope.checkCharginitem = function (tmp) {

                        $scope.PK = tmp.PK;
                        $scope.ITEMID = tmp.ITEMID;
                        $scope.ITEMNAME = tmp.ITEMNAME;
                        $scope.getLisCharginitemTest();
                    }
                    $scope.checkTest = function (index) {//点击行选择复选框
                        if ($scope.tests[index].check) {
                            $scope.tests[index].check = false;
                        } else {
                            $scope.tests[index].check = true;
                        }
                    }
                    $scope.checkT = [];
                    $scope.addLisCharginitemTest = function () {
                        if ($scope.ITEMNAME == "") {
                            alert("请选择匹配仪器");
                            return;
                        }
                        for (var i = 0; i < $scope.tests.length; i++) {//获取选中的项目
                            if ($scope.tests[i].check) {
                                $scope.checkT.push($scope.tests[i]);
                            }
                        }
                        if ($scope.checkT.length == 0) {
                            alert("请先为仪器选择项目在匹配");
                            return;
                        }
                        var checktes = JSON.stringify($scope.checkT);
                        $.post("citemtest/saveLisCharginitemTest", {TESTS: checktes, ITEMID: $scope.ITEMID, PK: $scope.PK}, function (data) {
                            if (data == 'true') {

                                $scope.getLisCharginitemTest();
                                $scope.getLisCharginitem();
                                $scope.checkT = [];
                            }
                        })
                    }

                    $scope.getLisCharginitemTest = function () {
                        $.post("citemtest/getLisCharginitemTest", {ITEMID: $scope.ITEMID}, function (data) {
                            if (data) {
                                $scope.citts = data;
                                $scope.$apply();
                            }
                        })
                    }
                    $scope.getLisCharginitemTest();

                    $scope.deleteLisCharginitemTest = function (tmp) {

                        $.post("citemtest/deleteLisCharginitemTest", {ITEMID: tmp.ITEMID, TESTID: tmp.TESTID}, function (data) {
                            if (data == 'true') {

                                $scope.getLisCharginitemTest();
                                $scope.getLisCharginitem();
                            }
                        })
                    }



                })
    </script>
</html>
